home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-01-03 | 1.3 KB | 65 lines | [TEXT/R*ch] |
- // ---------------------------------------------------------
- // class BitGrpMapper
- // ---------------------------------------------------------
-
-
- #ifndef NULL
- const void * const NULL = 0;
- #endif
-
- typedef unsigned long ulng;
-
- struct IndexEntry {
- long index[4];
- };
-
-
- class BitGrpMapper {
-
- public:
- static long ubTable[33];
- static long lbTable[33];
-
- long chunkSize; // 1, 2, 4 or 8 bits per chunk
- long chunkCount; // # of chunks/digits in group index
- ulng firstMask; // used to reset curMask
- ulng firstMatchBit;
- long numGrpLists;
-
- void Init( long chunkSize,
- long numBits );
-
- inline long LookUp( ulng value );
-
- private:
- static IndexEntry lookupTable2[];
- static IndexEntry lookupTable4[];
- static IndexEntry lookupTable8[];
-
-
- IndexEntry *lookupTable; // lookup group index
-
-
- #if WRITE_LOOKUP_TABLES == 1
- void CalcLookupTable( IndexEntry lookupTbl[],
- long chunkSz );
-
- void WriteLookupTable( ofstream &file,
- IndexEntry table[],
- char* tableName );
- #endif
- };
-
-
- inline long BitGrpMapper::LookUp( ulng value )
- {
- long index = lookupTable[value >> 24].index[0];
-
- index += lookupTable[(value >> 16) & 0xff].index[1];
- index += lookupTable[(value >> 8) & 0xff].index[2];
- index += lookupTable[value & 0xff].index[3];
-
- return index;
- }
-
-